package jdkSPI;
import java.util.Iterator;
import java.util.ServiceLoader;

public class SpiDemo {

        public static void main(String[] args) {

            ServiceLoader<Log> serviceLoader = ServiceLoader.load(Log.class);

            Iterator<Log> iterator = serviceLoader.iterator();

            while (iterator.hasNext()) {

                Log log = iterator.next();

                log.log("JDK SPI");

            }

        }

    }

// 输出如下:

// Log4j:JDK SPI

// Logback:JDK SPI

